#include <bits/stdc++.h>
using namespace std;
const int Mod = 1000000007;
int a[1000001];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  long long ans = 1;
  for (int i = 1; i <= n; i++) {
    ans = (ans * (a[i] - (i - 1))) % Mod;
  }
  cout << ans << endl;

  return 0;
}